/**
 * Created by chesw on 2017/5/10.
 */
(function () {
    new Vue({
        el: '#personal-center',
        data: {
            leftTab: {
                title: '个人中心',
                tabList: [{
                    list: [{ title: '我的预约', cls: GlobalValue.VALIDTAB, id: Personal.PATIENTAPPOINT },
                        { title: '我的病例', cls: GlobalValue.INVALIDTAB, id: Personal.CASESLIST },
                        { title: '我的就诊人', cls: GlobalValue.INVALIDTAB, id: Personal.MYDIAGNOSIS }]
                },
                    { list: [{ title: '个人资料设置', cls: GlobalValue.INVALIDTAB, id: Personal.PERSONALINFO }] }
                ]
            },
            showConfirm: false,
            showMid: Personal.PATIENTAPPOINT, //0: 我的预约人, 1：我的病例， 2：病例详情，3：我的就诊人
            confirm: {},
            showPageParam: {},
            showNewPageParam: {},
            userName: '',
            loginInfo: { isLogin: '', name: '', mobile: '',picUrl:'' },
            caseInfo: {},
            visitRecord: {},
            curPage: '',
            pageCount:''
        },
        created: function () {
            var _self = this;
            //检查登录状态
            CheckLoginStatus(_self, _self.loginInfo);           
        },
        mounted: function () {
            var _self = this;
            showHtml();
            //设置导航栏样式
            document.getElementById("Home").className = "invalid-nav";
            document.getElementById("OrderExpert").className = "invalid-nav";
            document.getElementById("DistinctMedical").className = "invalid-nav";
            document.getElementById("MedicalWiki").className = "invalid-nav";
            document.getElementById("News").className = "invalid-nav";
            document.getElementById("AboutUs").className = "invalid-nav";
           

            var p_TabValue = getQueryString("Tab");
            var p_first = getQueryString("first");
            var p_second = getQueryString("second");
            if (p_TabValue != null && p_first != null && p_second != null) {
                var p_param = { first: p_first, second: p_second, id: p_TabValue };
                _self.changeTab(p_param);
            }
            
        },
        components: {
            'clinic-head': clinicHead,
            'clinic-right': clinicRight,
            'clinic-foot': clinicFoot,
            'clinic-left-tab': clinicLeftTab,
            'patient-appoint': patientAppoint,
            'cases-list': casesList,
            'my-diagnosis': myDiagnosis,
            'personal-info': personalInfo,
            'clinic-page': clinicPage,
            'dialog-confirm': dialogConfirm
        },
        methods: {
            CheckPersonInfo: function () {
                var _self = this;
                var Welcome = document.getElementById("Welcome");
                var fillPersonInfo = document.getElementById("fillPersonInfo");
                if (_self.loginInfo.name === "" || _self.loginInfo.name === null) {
                    fillPersonInfo.style.display = "block";
                    Welcome.style.display = "none";
                    fillPersonInfo.href = "/PersonalCenter/Index?Tab=4&first=1&second=0"
                }
                else {
                    fillPersonInfo.style.display = "none";
                    Welcome.style.display = "block";
                }
            },
            changeTab: function (p_param) {
                this.showMid = p_param.id;
                this.visitRecord = {};
                this.leftTab = changeColorByLNav(this.leftTab, p_param.first, p_param.second);
            },
            confirmDialog: function (p_val) {
                var _self = this;
                if (p_val.type) {
                    _self.confirm = p_val;
                } else {
                    _self.leftTab = changeColorByLNav(this.leftTab, 0, 1);
                    _self.showMid = Personal.CASESLIST;
                    _self.visitRecord = p_val.visitRecord;
                }
            },
            showMyDiag: function (p_val) {
                //导航到“我的就诊人"
                this.leftTab = changeColorByLNav(this.leftTab, 0, 2);
                this.showMid = p_val;
            },
            detail: function (p_val,p_param) {
                var _self = this;
                _self.showMid = p_val;
                _self.caseInfo = p_param;               
            },
            showPage: function (p_param) {
                var _self = this;
                _self.showPageParam = p_param;
            }
        }
    })
})()

